class Solution:
    def isSubstringPresent(self, s: str) -> bool:
        Exist = [[0]*26 for i in range(26)]
        for i in range(len(s)-1):
            m = ord(s[i]) - ord('a')
            n = ord(s[i+1]) - ord('a')
            if Exist[n][m] == 1 or m == n:
                return True
            Exist[m][n] = 1
        return False

if __name__ == "__main__":
    s = Solution()
    print(s.isSubstringPresent(s = "leetcode"))
    print(s.isSubstringPresent(s = "abcba"))
    print(s.isSubstringPresent(s = "abcd"))
    